//
//  AIFAddAccountManager.m
//  PywSdk
//
//  Created by smallwave on 16/8/29.
//  Copyright © 2016年 zero. All rights reserved.
//

#import "AIFAddAccountManager.h"

@implementation AIFAddAccountManager

NSString *const AddAccount_SIGN = @"sign";
NSString *const AddAccount_PASSPORT = @"passport";
NSString *const AddAccount_GAMEID = @"gameid";
NSString *const AddAccount_TID = @"tid";
NSString *const AddAccount_Passport_token = @"passport_token";

- (instancetype)init
{
    self = [super init];
    if (self) {
        self.child = self;
        self.paramSource = self;
        self.validate = self;
    }
    return self;
}


#pragma mark - ETAPIManager
/**
 *  方法名称
 *
 *  @return methodName
 */
- (NSString *)methodName
{
    return URL_ADDACCOUNT;
}
- (NSString *)seriviceType
{
    return [PywAppInfo sharedAppInfo].seriviceType;
}

/**
 *  请求类型
 *
 *  @return request type
 */
- (ETAPIManagerRequestType)requestType
{
    return ETAPIManagerRequestTypePost;
}



#pragma mark - ETAPIManagerParamSourceDelegate
- (NSDictionary *)paramsForApi:(ETApiBaseManager *)manager
{
    NSString *passport = [PywPlatformMain sharedPlatformMain].passport;
    NSString *gameid = [PywAppInfo sharedAppInfo].gameId;
    
    NSString *tid = [[PywAppInfo sharedAppInfo] tid];
    NSString *apiSecret2 = [AppUtil getApiSecret2:tid apiSecret:[PywAppInfo sharedAppInfo].apisecret];
    
    NSString *sign = [NSString stringWithFormat:@"%@%@%@",gameid,passport,apiSecret2];
    sign = [PywCipherUtils md5:sign];
    NSString *passport_token = [PywPlatformMain sharedPlatformMain].passport_Token;
    
    MutableDictionary *param = [[MutableDictionary alloc] init];
    [param setObject:passport forKey:AddAccount_PASSPORT];
    [param setObject:gameid forKey:AddAccount_GAMEID];
    [param setObject:tid forKey:AddAccount_TID];
    [param setObject:sign forKey:AddAccount_SIGN];
    [param setObject:passport_token forKey:AddAccount_Passport_token];
    return param;
}

#pragma mark - ETAPIManagerValidator
- (BOOL)manager:(ETApiBaseManager *)manager isCorrectWithParamsData:(NSDictionary *)data{
    return YES;
}

- (BOOL)manager:(ETApiBaseManager *)manager isCorrectWithCallBackData:(NSDictionary *)data{
    return YES;
}

@end
